<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <ul>
    <li>我是列表项1</li>
    <li class="li2">我是列表项2</li>
    <li>我是列表项3</li>
  </ul>
  <script>
  
    // 获取第二li
    var son = document.querySelector('.li2');
    console.log(son);

    son.onclick = function() {
      // this → son
      // var ul = this.parentNode;  // 找父元素
      // ul.style.background = 'red';

      var body= this.parentNode.parentNode; // 找父元素的父元素
      body.style.background = 'hotpink';
s
    }
  </script>
</body>
</html>